package com.taiyuan.tongcheng.ui;

import org.kymjs.kjframe.ui.BindView;

import android.content.Intent;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.tytc56.user.R;

public class DriverMsgActivity extends BaseActivity {
	@BindView(id = R.id.etv_driver_msg)
	private EditText msgInputEtv;
	@BindView(id = R.id.tv_driver_input)
	private TextView msgCount;
	@BindView(id = R.id.btn_msg_sub,click=true)
	private Button  submit;
	
	private int length = 0;
	private Intent  resultIntent;

	@Override
	public void setRootView() {
		setContentView(R.layout.activity_driver_msg);
	}

	@Override
	public void initWidget() {
		super.initWidget();
		initView();
		rightTv.setVisibility(View.GONE);
		resultIntent=getIntent();
		msgInputEtv.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				msgCount.setText((60 - count) + "/60");
				length = 60 - msgInputEtv.getText().length();
			}
			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {

			}
			@Override
			public void afterTextChanged(Editable s) {
				msgCount.setText(length + "/60");
			}
		});
		
		topTv.setText(R.string.lable_driver_msg);
	}
	
	
	@Override
	public void widgetClick(View v) {
		super.widgetClick(v);
		switch (v.getId()) {
		case R.id.btn_top_back:
			DriverMsgActivity.this.finish();
			break;
		case R.id.btn_msg_sub:
			if(msgInputEtv.getText().length()>0){
				resultIntent.putExtra("MESSAGE", msgInputEtv.getText().toString());
				setResult(RESULT_OK, resultIntent);
				this.finish();
			}else{
				
			}
			break;

		default:
			break;
		}
	}

}
